package com.lyq.demo.redis.listener;

import com.lyq.demo.redis.annotation.MsgListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;

/**
 * @author lyq
 * @time 2019/5/11 20:31
 */
@Slf4j
@MsgListener(topic = "register")
public class SmsListener implements MessageListener {

    @Override
    public void onMessage(Message message, byte[] bytes) {
        log.info("SmsListener收到一个message,thread={}",Thread.currentThread().getName());
        String body = new String(message.getBody());
        String channel = new String(message.getChannel());
        log.info("收到的消息：body={},channel={}",body,channel);
        String str = new String(bytes);
        log.info("收到的bytes={}",str);
    }
}
